﻿<UserControl x:Class="ProgrammersCalculator.View.NumberConversion"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:view="clr-namespace:ProgrammersCalculator.Model"
             xmlns:con="clr-namespace:ProgrammersCalculator.Convertor"
             mc:Ignorable="d">
    <UserControl.Resources>
        <con:NumberSystemConverter x:Key="myConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Margin="0,15,0,0">
        <StackPanel x:Name="ContentStackPanel">
            <Grid Margin="0,10,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />

                </Grid.RowDefinitions>
                
                <Label Content="Enter Decimal Number:"
                       HorizontalAlignment="Right" />
                <TextBox Grid.Column="1"
                         Margin="2"
                         Text="{Binding Decimal,Mode=TwoWay}"
                         x:Name="txtDecimal" />

                <Label Content="Binary Equivalent:"
                       Grid.Row="1"
                       HorizontalAlignment="Right" />
                <TextBox Grid.Column="1"
                         Grid.Row="1"
                         Margin="2"
                         Text="{Binding ElementName=txtDecimal,Path=Text,Converter={StaticResource myConverter},ConverterParameter=2}" />

                <Label Content="Octal Equivalent:"
                       Grid.Row="2"
                       HorizontalAlignment="Right" />
                <TextBox x:Name="textBox"
                         Grid.Column="1"
                         Grid.Row="2"
                         Margin="2"
                         Text="{Binding ElementName=txtDecimal,Path=Text,Converter={StaticResource myConverter},ConverterParameter=8}" />



                <Label Content="Hex Equivalent:"
                       Grid.Row="3"
                       HorizontalAlignment="Right" />
                <TextBox Grid.Column="1"
                         Grid.Row="3"
                         Margin="2"
                         Text="{Binding ElementName=txtDecimal,Path=Text,Converter={StaticResource myConverter},ConverterParameter=16}" />
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>
